<?php
namespace PsiFramework\Applications\Bibliotheque\Classes\Services;

import("Applications.Bibliotheque.Classes.DAO.AuteurDAO");
import("Classes.Services.AbstractService");

use \PsiFramework\Applications\Bibliotheque\Classes\DAO\AuteurDAO;
use \PsiFramework\Classes\Services\AbstractService;

/**
 * Bibliotheque
 * Gestion de ma bibliothèque
 *
 * @author Rémi San
 * @version beta
 */

/**
 * Service de listing des auteurs
 *
 * @package Services
 */
class ListAuteursService extends AbstractService
{

    /**
     * Constructor
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * The main function of the method which is called every time
     * an service is created by the front controller.
     *
     * @param $request      the HTTP request to be treated by the action
     */
    public function execute(/*Request*/ $request)
    {
        parent::execute($request);

        $auteurs = array();
        if ($this->_value !== null && $this->_value !== "") {
            $auteurDao = DAOFactory::getDAO("Auteur");
            $auteurs = $auteurDao->retrieveByPartialName($this->_value);
        }

        $this->_response->setAttribute("objects", $auteurs);
        $this->show("xml");
    }
}
